home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: seebs@solutions.solon.com (Peter Seebach)
- Newsgroups: comp.lang.c
- Subject: Re: operator % - compiler error
- Date: 19 Mar 1996 06:27:22 -0600
- Organization: Usenet Fact Police (Undercover)
- Message-ID: <4im97a$dm5@solutions.solon.com>
- References: <4ihuuh$6ul@hatathli.csulb.edu> <314DD835.33BE@willows.com>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <314DD835.33BE@willows.com>,
- Tarang Deshpande <tarang@willows.com> wrote:
- >David Cho wrote:
- >> When I try to compile, I get an erro message for the following line:
- >> x=663608941*y%pow(2,32) /*I want remainder*/
- >> But the error message says "illegal use of floating point". What does
- >> that mean? Isn't % used a an operator to calcuate the remainder?
-
- >Although the % operator calculates the remainder it does so for two
- >ints and not two floats or double. You need to change your code to
-
- >x = ( long )( 663608941 * y ) % ( long )( pow ( 2, 32 ) );
-
- As you correctly demonstrate, it actually works on two integral types,
- not two ints. The (long) on the left is probably redundant.
-
- Note that it's quite possible that (long) pow(2, 32) is 0. It's also
- possible that it causes a crash.
-
- -s
- --
- Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
- C/Unix wizard -- C/Unix questions? Send mail for help. No, really!
- FUCK the communications decency act. Goddamned government. [literally.]
- The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
-